<template>
<div>

    <van-cell-group>
        <van-nav-bar :fixe="true" :placeholder="true" title="" left-text="返回" left-arrow @click-left="onClickLeft" />
        <van-tabbar v-model="active" :fixed="false" @change="onChange">
            <van-tabbar-item>加班备案</van-tabbar-item>
            <van-tabbar-item>请休假</van-tabbar-item>
            <!-- <van-tabbar-item>离穗报备</van-tabbar-item> -->
            <van-tabbar-item>出国境</van-tabbar-item>
        </van-tabbar>
    </van-cell-group>

    <van-tabs v-model="active">
        <van-tab title="标签 1">
            <van-cell-group v-if="jb">
                <van-cell title="待审核加班" is-link to="jbsh" :value=this.dsh />
                <van-cell title="已审核加班" is-link to="yshjb" :value=this.ysh />
            </van-cell-group>
        </van-tab>
        <van-tab title="标签 2">
            <van-cell-group v-if="qxj">
                <van-cell title="待审核请休假" is-link to="dshqxj" :value=this.dshqxj />
                <van-cell title="已审核请休假" is-link to="yshqxj" :value=this.yshqxj />
                <van-cell title="待办理销假" is-link to="xj" :value=this.dblxj />
            </van-cell-group>
        </van-tab>
        <van-tab title="标签 3">
            <van-cell-group v-if="lsbb">
                <van-cell title="新增因公离穗备案" is-link to="xjlsbb" value="" />
                <van-cell title="新增公休节假日离开广州" is-link to="gxjjrlkgz" value="" />
            </van-cell-group>
        </van-tab>
        <van-tab title="标签 4">
            <van-cell-group v-if="cgj">
                <van-cell title="出国境审核" is-link to="cgjsh" :value=this.cgjsh />
                <van-cell title="填写回执单" is-link to="txhzdList" :value=this.txhzdList />
                <van-cell title="收回证件" is-link to="dshzj" :value=this.dshzj />
                <van-cell title="人事处发证、发函、呈报" is-link to="rscfz" :value=this.rscfz />
            </van-cell-group>
        </van-tab>
    </van-tabs>

    <van-tabbar v-model="active1">
        <van-tabbar-item icon="home-o" to='/index'>首页</van-tabbar-item>
        <van-tabbar-item icon="search" to='/bl'>办理</van-tabbar-item>
        <van-tabbar-item icon="friends-o" to='/indexxj'>新建</van-tabbar-item>

        <van-tabbar-item icon="manager-o" to='/wode'>我的</van-tabbar-item>
    </van-tabbar>
</div>
</template>

<script>
import Cookies from "js-cookie";
import {
    findList,
    cgjfindList
} from "@/api/fy";
import {
    Transformation
} from "@/api/common";
export default {
    data() {
        return {

            // active: Cookies.get("active"),
            active:0,
            active1: 1,
            jb: true,
            qxj: false,
            lsbb: false,
            cgj: false,
            dsh: '',
            ysh: '',
            dshqxj: '',
            yshqxj: '',
            dblxj: '',
            cgjsh: '',
            txhzdList: '',
            dshzj: '',
            rscfz: ''

        };
    },
    created() {
        this.dshjb();
        this.yshjb();
        this.active= Number(Cookies.get("active"))
        if (this.active == 0) {
            this.jb = true
            this.qxj = false
            this.lsbb = false
            this.cgj = false
        } else if (this.active == 1) {
            this.jb = false
            this.qxj = true
            this.lsbb = false
            this.cgj = false
            this.daishenheqxj();
            this.daibanlixiaojia();
            this.yishenheqingxiujia();
        } else if (this.active == 2) {
            this.jb = false
            this.qxj = false
            this.lsbb = true
            this.cgj = false  
        } else if (this.active == 3) {
            this.jb = false
            this.qxj = false
            this.lsbb = false
            this.cgj = true
            this.chuguojingshenhe();
            this.tianxiehuizhandan();
            this.shouhuizhengjian();
            this.resnshichufanhanchengbao();
        }

    },
    methods: {
        onChange(index) {
            if (index == 0) {
                this.jb = true
                this.qxj = false
                this.lsbb = false
                this.cgj = false
                Cookies.set("active", 0, {
                    expires: 7,
                    path: "/"
                });
            } else if (index == 1) {
                this.jb = false
                this.qxj = true
                this.lsbb = false
                this.cgj = false
                this.daishenheqxj();
                this.daibanlixiaojia();
                this.yishenheqingxiujia();

                Cookies.set("active", 1, {
                    expires: 7,
                    path: "/"
                });
            } else if (index == 2) {
                this.jb = false
                this.qxj = false
                this.lsbb = true
                this.cgj = false
                  Cookies.set("active", 2, {
                    expires: 7,
                    path: "/"
                });
            } else if (index == 3) {
                this.jb = false
                this.qxj = false
                this.lsbb = false
                this.cgj = true
                this.chuguojingshenhe();
                this.tianxiehuizhandan();
                this.shouhuizhengjian();
                this.resnshichufanhanchengbao();
                  Cookies.set("active", 3, {
                    expires: 7,
                    path: "/"
                });
            }
        },

        onClickLeft() {
            this.$router.go(-1);
        },
        dshjb() {
            const that = this;
            const obj = {
                page: 1,
                limit: 10,
                queryType: "WORK",
                recordType: "",
                status: 2,
                dataLimitType: 3,
                userId: Cookies.get("userId"),
                applyTimeStart: '',
                applyTimeEnd: '',
            };
            console.log(obj);
            findList(obj).then(function (res) {
                that.dsh = res.data.total;
            });

        },
        yshjb() {

            const that = this;

            const obj = {
                page: 1,
                limit: 10,
                queryType: "WORK",
                recordType: "",
                status: 5,
                dataLimitType: 4,
                userId: Cookies.get("userId"),
                applyTimeStart: '',
                applyTimeEnd: '',
            };
            console.log(obj);
            findList(obj).then(function (res) {
                that.ysh = res.data.total;
            });
        },
        daishenheqxj() {

            const that = this;

            const obj = {
                page: 1,
                limit: 10,
                queryType: "LEAVE",
                recordType: "",
                status: 2,
                dataLimitType: 3,
                userId: Cookies.get("userId"),
                applyTimeStart: '',
                applyTimeEnd: '',
            };
            console.log(obj);
            findList(obj).then(function (res) {
                that.dshqxj = res.data.total;
            });
        },
        yishenheqingxiujia() {

            const that = this;

            const obj = {
                page: 1,
                limit: 10,
                queryType: "LEAVE",
                recordType: "",
                status: '',
                dataLimitType: 4,
                userId: Cookies.get("userId"),
                applyTimeStart: '',
                applyTimeEnd: '',
            };
            console.log(obj);
            findList(obj).then(function (res) {
                that.yshqxj = res.data.total;
            });
        },
        daibanlixiaojia() {

            const that = this;

            const obj = {
                page: 1,
                limit: 10,
                queryType: "LEAVE",
                recordType: "",
                status: 41,
                dataLimitType: 1,
                userId: Cookies.get("userId"),
                applyTimeStart: '',
                applyTimeEnd: '',
            };
            console.log(obj);
            findList(obj).then(function (res) {
                that.dblxj = res.data.total;
            });
        },
        chuguojingshenhe() {
            const that = this;

            const obj = {
                page: 1,
                limit: 10,
                recordType: "ABROAD",
                status: 2,
                dataLimitType: 3,
                userId: Cookies.get("userId"),
                applyTimeStart: '',
                applyTimeEnd: '',
            };
            cgjfindList(obj).then(function (res) {
                that.cgjsh = res.data.total;
            })
        },
        tianxiehuizhandan() {
            const that = this;

            const obj = {
                page: 1,
                limit: 10,
                recordType: "ABROAD",
                status: 42,
                dataLimitType: 3,
                userId: Cookies.get("userId"),
            };
            cgjfindList(obj).then(function (res) {
                that.txhzdList = res.data.total;
            })
        },
        shouhuizhengjian() {
            const that = this;

            const obj = {
                page: 1,
                limit: 10,
                queryType: "ABROAD",
                recordType: "",
                status: 43,
                dataLimitType: 3,
                userId: Cookies.get("userId"),
                applyTimeStart: '',
                applyTimeEnd: '',
            };
            cgjfindList(obj).then(function (res) {
                that.dshzj = res.data.total;
            })
        },
        resnshichufanhanchengbao() {
            const that = this;

            const obj = {
                page: 1,
                limit: 10,
                queryType: "ABROAD",
                recordType: "",
                status: 44,
                dataLimitType: 3,
                userId: Cookies.get("userId"),
                applyTimeStart: '',
                applyTimeEnd: '',
            };
            cgjfindList(obj).then(function (res) {
                that.rscfz = res.data.total;
            })
        },
    }
};
</script>

<style>
</style>
